package com.atguigu.realtime.function;

import com.atguigu.realtime.util.IKUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.Collection;

/**
 * @author chenlongStart
 * @create 2021-07-05 10:59
 * @desc
 */
@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public class KeyWordUdtf extends TableFunction<Row> {

    public void eval(String kw) {
        Collection<String> words = IKUtil.analyzer(kw);
        for (String word : words) {
            collect(Row.of(word));
        }
    }
}
